pkg_name=bzip2
version=1.0.6
src_dir=$src_dir_root/$pkg_name-$version
url=http://www.bzip.org/$version/$pkg_name-$version.tar.gz

cd "$src_dir_root"
rm -Rf "$pkg_name-$version"
tar zxf "$pkg_name-$version.tar.gz"

cd "$src_dir"

make -f Makefile-libbz2_so \
	CC=$gnu_target-gcc \
	CFLAGS="-fpic -fPIC -Wall -Winline -O0 -D_FILE_OFFSET_BITS=64" \
	all

install_tmp_dir=/tmp/$pkg_name-cross-$version
rm -Rf "$install_tmp_dir"
mkdir -p "$install_tmp_dir"

mkdir -p "$install_tmp_dir/lib"
mkdir -p "$install_tmp_dir/bin"
mkdir -p "$install_tmp_dir/include"

cp -f libbz2.so.1.0.6 "$install_tmp_dir/lib"
chmod 755 "$install_tmp_dir/lib/libbz2.so.1.0.6"
ln -sf libbz2.so.1.0.6 "$install_tmp_dir/lib/libbz2.so.1.0"
ln -sf libbz2.so.1.0 "$install_tmp_dir/lib/libbz2.so"
cp -f bzip2-shared "$install_tmp_dir/bin/bzip2"
chmod 755 "$install_tmp_dir/bin/bzip2"
cp -f bzlib.h "$install_tmp_dir/include"
chmod 644 "$install_tmp_dir/include/bzlib.h"

install_dirs_in_sysroot "$builders_dir_root/$pkg_name/runtime-cross.dirs" "$sysroot/"
install_files_in_sysroot "$builders_dir_root/$pkg_name/runtime-cross.files" "$install_tmp_dir/" "$sysroot/"
install_links_in_sysroot "$builders_dir_root/$pkg_name/runtime-cross.links" "$sysroot/"
install_dirs_in_sysroot  "$builders_dir_root/$pkg_name/devel-cross.dirs" "$sysroot/"
install_files_in_sysroot "$builders_dir_root/$pkg_name/devel-cross.files" "$install_tmp_dir/" "$sysroot/"
install_links_in_sysroot "$builders_dir_root/$pkg_name/devel-cross.links" "$sysroot/"
elf_strip_in_sysroot "$builders_dir_root/$pkg_name/elf-strip-cross" "$sysroot/"

rm -Rf "$install_tmp_dir"
rm -Rf "$build_dir"
rm -Rf "$src_dir"
